package me.shurufa.activities;

import android.content.pm.PackageManager;
import android.os.Bundle;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.widget.ImageView;
import android.widget.TextView;

import butterknife.Bind;
import me.shurufa.R;

/**
 * 点击设置页SettingsActivity 跳转此页面
 *
 * @FileName: me.shurufa.activities.AboutUsActivity.java
 * @author: kHRYSTAL
 * @email: 723526676@qq.com
 * @date: 2016-01-19 11:27
 */
public class AboutUsActivity extends BaseActivity {


    @Bind(R.id.left_text)
    TextView leftText;
    @Bind(R.id.right_image)
    ImageView rightImage;
    @Bind(R.id.right_text)
    TextView rightText;
    @Bind(R.id.version_text)
    TextView versionText;
    @Bind(R.id.about_text)
    TextView aboutUsText;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        activity_layout_res = R.layout.activity_about_us;
        super.onCreate(savedInstanceState);
        initUI();
    }

    private void initUI() {
        titleTextView.setText(getString(R.string.about_us));
        aboutUsText.setAutoLinkMask(Linkify.WEB_URLS);
        aboutUsText.setMovementMethod(LinkMovementMethod.getInstance());
        if (!TextUtils.isEmpty(getVersionName()))
            versionText.setText(String.format(getString(R.string.version_name),getVersionName()));
    }

    private String getVersionName(){
        String pkName = this.getPackageName();
        try {
            String versionName = this.getPackageManager().getPackageInfo(
                    pkName, 0).versionName;
            return versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return null;
    }
}
